Comments

alippai’s picture

Assigned: Unassigned » alippai
Status: Active » Needs review
StatusFileSize
new2.15 KB

Not tested, not benchmarked.

alippai’s picture

StatusFileSize
new2.13 KB

Status: Needs review » Needs work

The last submitted patch, 835672-memoryqueue.patch, failed testing.

alippai’s picture

Status: Needs work » Needs review
StatusFileSize
new2.1 KB

Status: Needs review » Needs work

The last submitted patch, 835672-memoryqueue.patch, failed testing.

alippai’s picture

StatusFileSize
new2.96 KB
alippai’s picture

Status: Needs work » Needs review
alippai’s picture

StatusFileSize
new556 bytes

Memory benchmark (in bytes):

# of items without patch patched
10 111056 106544
50 132696 116464
100 159752 128864
500 375696 228064
1000 645744 352064
5000 3047840 1573440
10000 - 3075584
50000 - 14568448
100000 - 29065600
500000 - 140848512

- means not executed in 300 seconds, with patch last executed in cca 10.1 seconds.

The testcode:

<?php
define('DRUPAL_ROOT', getcwd());

require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

$mem_start = memory_get_usage();
$time_start = microtime(true);

$queue = new MemoryQueue();
$queue->createQueue();
for($i = 0; $i<10000; $i++) {
  $queue->createItem($i);
}
$queue->createQueue();
for($i = 0; $i<10000; $i++) {
  $queue->claimItem()->data;
}

$time_end = microtime(true);
$time = $time_end - $time_start;
$mem_end = memory_get_usage();
$mem = $mem_end - $mem_start;

echo "$time seconds, $mem memory\n";

AB benchmark coming tomorrow.

chx’s picture

Status: Needs review » Needs work

Wow! Very interesting nice work. However, claimItem should put the queue key in the item so that release and delete can reuse that.

yched’s picture

+++ modules/system/system.queue.inc	24 Jun 2010 13:58:29 -0000
@@ -307,61 +307,45 @@
+  public function deleteItem($item) {
+    for($i = 0; $i < $this->queue->count(); $i++) {
+      if($this->queue->current() === $item) {
+        $this->queue->offsetUnset($this->queue->key());
+      }
+      $this->queue->next();

Isn't there a smarter way than looping through the whole queue to find the item ?
At the very least, it looks like the loop should break once the item was found ?

+ missing whitespace after 'for' and 'if'.

57 critical left. Go review some!

yched’s picture

Hm, also, it looks like this API is only available in PHP 5.3, which would be a no go for drupal core.

alippai’s picture

There is prettier way to iterate, but we have to iterate thru it.

SPL is available and compiled by default in PHP 5.0.0 and can't be disabled from version 5.3.0.
If we use it, it should be added to the Drupal requirements.

Go or no go? Go only for D8?

alippai’s picture

SPL is already required - system.install, line 117

I'm going to continue my work now.

P.S.: Thanks to catch for pointing this out.

alippai’s picture

Status: Needs work » Needs review
StatusFileSize
new3.58 KB

Who calls releaseItem()? If the "claimer" has to, in that case he doesn't know the expiration time in the SystemQueue (maybe a bug?). Should be there a scheduler for every queue?

chx’s picture

Status: Needs review » Needs work

You are not getting me. You should not iterate your queue when deleting / releasing. Put the index in claimItem into $item: $item = $this->queue->current(); $item->key = $this->queue->key(); return $item reuse it in deleteItem: $this->queue->offsetUnset($item->key);

Also SplQueue extends SplDoublyLinkedList implements Iterator , ArrayAccess please use array notation, isnt that simpler? But also please dont forget to re-benchmark to do it. ($queue = $this->queue; unset($queue[$item->key]);)

As for releaseItem and expire, I dont get your question. You are leasing the item for say 30 seconds. If you are not done in 30 seconds, another process might get the chance to process the item. If you are done, just call deleteItem. If you bail out early because say you wanted to reach an external resource and there is a network error then call releaseItem so that another process can try again. You do not need a scheduler for any of these.

alippai’s picture

Status: Needs work » Needs review
StatusFileSize
new3.45 KB

Some work on this.

Status: Needs review » Needs work

The last submitted patch, 835672-14-memoryqueue.patch, failed testing.

alippai’s picture

StatusFileSize
new3.41 KB

Left there $this->...

alippai’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 835672-18-memoryqueue.patch, failed testing.

alippai’s picture

With this patch there is no difference in memory load and execution time (with or without the patch), i have to figure this out later.

mikedillion’s picture

Status: Needs work » Needs review

#14: 835672-14-memoryqueue.patch queued for re-testing.

catch’s picture

Version: 7.x-dev » 8.x-dev

Moving this to 8. Looks like a candidate for backport though if the previous numbers hold up.

catch’s picture

Status: Needs review » Needs work
alippai’s picture

Status: Needs work » Needs review
StatusFileSize
new2.45 KB

Okay, this patch may be oversimplified, but the results are nice:

Class #no Time Memory
Memory 10 0.0027821063995361 seconds 51328 bytes
Memory 50 0.0017189979553223 seconds 36856 bytes
Memory 100 0.0039970874786377 seconds 46208 bytes
Memory 500 0.06383490562439 seconds 427408 bytes
Memory 1000 0.24434113502502 seconds 453248 bytes
Memory 5000 17.965664148331 seconds 4035976 bytes
SplMemory 10 0.0023579597473145 seconds 7216 bytes
SplMemory 50 0.00087809562683105 seconds 656 bytes
SplMemory 100 0.00105881690979 seconds 640 bytes
SplMemory 500 0.0025920867919922 seconds 640 bytes
SplMemory 1000 0.0039441585540771 seconds 664 bytes
SplMemory 5000 0.016144037246704 seconds 624 bytes
SplMemory 10000 0.042448997497559 seconds 306232 bytes
SplMemory 50000 0.2129168510437 seconds 3146392 bytes
SplMemory 100000 0.39085483551025 seconds 4195096 bytes

This patch changes the behavior. When you claim an item, you remove it from the queue. When you release the item, you put it back. This way it doesn't have a item_id (and there is no need for that).
I don't know about it's usage in the core, but the tests are green. :P

alippai’s picture

Also we should update the BatchMemory implementation.
About the stdClass() wrapper for the data: it's needed to match the "interface", but we don't use it now in this implementation.

Status: Needs review » Needs work
Issue tags: -Performance

The last submitted patch, d8-835672-25-memoryqueue.patch, failed testing.

alippai’s picture

Status: Needs work » Needs review

#25: d8-835672-25-memoryqueue.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +Performance

The last submitted patch, d8-835672-25-memoryqueue.patch, failed testing.

alippai’s picture

StatusFileSize
new3.3 KB

Fixed BatchMemory.

alippai’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: -Performance

The last submitted patch, d8-835672-30-memoryqueue.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review

#30: d8-835672-30-memoryqueue.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, d8-835672-30-memoryqueue.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Issue summary: View changes
Status: Needs work » Postponed (maintainer needs more info)
Issue tags: +stale-issue-cleanup

Thank you for creating this issue to improve Drupal.

We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Thanks!

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

Since there has been no follow up in 3 months going to close out. But don't worry they can always be re-opened.

Thanks all!