|
|
DescriptionSkOnce: 2 bytes -> 1 byte
This uses the same logic we worked out for SkOncePtr to reduce
the memory footprint of SkOnce from a done byte and lock byte
to a single 3-state byte:
- NotStarted: no thread has tried to run fn() yet
- Active: a thread is running fn()
- Done: fn() is complete
Threads which see Done return immediately.
Threads which see NotStarted try to move to Active, run fn(), then move to Done.
Threads which see Active spin until the active thread moves to Done.
This additionally fixes a too-weak memory order bug in SkOncePtr,
and adds a big note to explain.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1904483003
Committed: https://skia.googlesource.com/skia/+/df02d338be8e3c1c50b48a3a9faa582703a39c07
Committed: https://skia.googlesource.com/skia/+/650f9e9a2630026d578970c6d031d7d4644f63b4
Patch Set 1 #Patch Set 2 : memory order bug fix #Patch Set 3 : note #
Total comments: 4
Patch Set 4 : Done Check, Calling #Patch Set 5 : basic uint8_t type #Messages
Total messages: 31 (15 generated)
Description was changed from ========== SkOnce: 2 bytes -> 1 byte This uses the same 3-state logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. BUG=skia: ========== to ========== SkOnce: 2 bytes -> 1 byte This uses the same 3-state logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... ==========
Description was changed from ========== SkOnce: 2 bytes -> 1 byte This uses the same 3-state logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... ========== to ========== SkOnce: 2 bytes -> 1 byte This uses the same logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single 3-state byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... ==========
Description was changed from ========== SkOnce: 2 bytes -> 1 byte This uses the same logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single 3-state byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... ========== to ========== SkOnce: 2 bytes -> 1 byte This uses the same logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single 3-state byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... ==========
The CQ bit was checked by mtklein@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1904483003/1 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1904483003/1
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by mtklein@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1904483003/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1904483003/20001
Description was changed from ========== SkOnce: 2 bytes -> 1 byte This uses the same logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single 3-state byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... ========== to ========== SkOnce: 2 bytes -> 1 byte This uses the same logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single 3-state byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. This additionally fixes a too-weak memory order bug in SkOncePtr, and adds a big note to explain. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... ==========
The CQ bit was checked by mtklein@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1904483003/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1904483003/40001
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
mtklein@chromium.org changed reviewers: + herb@google.com
https://codereview.chromium.org/1904483003/diff/40001/include/private/SkOnce.h File include/private/SkOnce.h (right): https://codereview.chromium.org/1904483003/diff/40001/include/private/SkOnce.... include/private/SkOnce.h:26: if (state == NotStarted) { Instead of having: if (state == NotStarted) { ... } while (state == Active) { ... } could you wrap the whole thing in while. while (state != Done) { if (state == NotStarted) { ... } } Making this change will reduce this code to using a single branch in the common case, and while (state != Done) is a clearer invariant of the state needed to proceed. https://codereview.chromium.org/1904483003/diff/40001/include/private/SkOnce.... include/private/SkOnce.h:44: enum State : uint8_t { NotStarted, Active, Done}; To me, calling the state Initializing is clearer than Active.
The CQ bit was checked by mtklein@chromium.org
https://codereview.chromium.org/1904483003/diff/40001/include/private/SkOnce.h File include/private/SkOnce.h (right): https://codereview.chromium.org/1904483003/diff/40001/include/private/SkOnce.... include/private/SkOnce.h:26: if (state == NotStarted) { On 2016/04/20 at 16:38:37, herb_g wrote: > Instead of having: > if (state == NotStarted) { > ... > } > while (state == Active) { > ... > } > > could you wrap the whole thing in while. > > while (state != Done) { > if (state == NotStarted) { > ... > } > } > > Making this change will reduce this code to using a single branch in the common case, and while (state != Done) is a clearer invariant of the state needed to proceed. Done. https://codereview.chromium.org/1904483003/diff/40001/include/private/SkOnce.... include/private/SkOnce.h:44: enum State : uint8_t { NotStarted, Active, Done}; On 2016/04/20 at 16:38:37, herb_g wrote: > To me, calling the state Initializing is clearer than Active. I've changed it to Calling.
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1904483003/60001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1904483003/60001
Note for Reviewers: The CQ is waiting for an approval. If you believe that the CL is not ready yet, or if you would like to L-G-T-M with comments then please uncheck the CQ checkbox. Waiting for LGTM from valid reviewer(s) till 2016-04-20 23:44 UTC
lgtm
Message was sent while issue was closed.
Description was changed from ========== SkOnce: 2 bytes -> 1 byte This uses the same logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single 3-state byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. This additionally fixes a too-weak memory order bug in SkOncePtr, and adds a big note to explain. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... ========== to ========== SkOnce: 2 bytes -> 1 byte This uses the same logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single 3-state byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. This additionally fixes a too-weak memory order bug in SkOncePtr, and adds a big note to explain. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... Committed: https://skia.googlesource.com/skia/+/df02d338be8e3c1c50b48a3a9faa582703a39c07 ==========
Message was sent while issue was closed.
Committed patchset #4 (id:60001) as https://skia.googlesource.com/skia/+/df02d338be8e3c1c50b48a3a9faa582703a39c07
Message was sent while issue was closed.
On 2016/04/20 17:54:57, commit-bot: I haz the power wrote: > Committed patchset #4 (id:60001) as > https://skia.googlesource.com/skia/+/df02d338be8e3c1c50b48a3a9faa582703a39c07 Das roll is geborked: https://build.chromium.org/p/tryserver.blink/builders/linux_blink_rel/builds/... clang: error: linker command failed with exit code 1 (use -v to see invocation) FAILED: python "/b/build/slave/linux_layout/build/src/build/toolchain/gcc_solink_wrapper.py" --readelf="readelf" --nm="nm" --sofile="./libmus_library.so" --tocfile="./libmus_library.so.TOC" --output="./libmus_library.so" -- ../../third_party/llvm-build/Release+Asserts/bin/clang++ -shared -Wl,--fatal-warnings -fPIC -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -B../../third_party/binutils/Linux_x64/Release/bin -fuse-ld=gold -Wl,--icf=all -pthread -m64 -Wl,-O1 -Wl,--gc-sections -Wl,--as-needed --sysroot=../../build/linux/debian_wheezy_amd64-sysroot -Wl,--export-dynamic -o "./libmus_library.so" -Wl,-soname="libmus_library.so" @"./libmus_library.so.rsp" ../../third_party/skia/include/private/SkOnce.h:24: error: undefined reference to 'std::atomic<SkOnce::State>::load(std::memory_order) const' ../../third_party/skia/include/private/SkOnce.h:33: error: undefined reference to 'std::atomic<SkOnce::State>::compare_exchange_strong(SkOnce::State&, SkOnce::State, std::memory_order)' ../../third_party/skia/include/private/SkOnce.h:36: error: undefined reference to 'std::atomic<SkOnce::State>::store(SkOnce::State, std::memory_order)' ../../third_party/skia/include/private/SkOnce.h:42: error: undefined reference to 'std::atomic<SkOnce::State>::load(std::memory_order) const' ../../third_party/skia/include/gpu/../private/SkOnce.h:24: error: undefined reference to 'std::atomic<SkOnce::State>::load(std::memory_order) const' ../../third_party/skia/include/gpu/../private/SkOnce.h:33: error: undefined reference to 'std::atomic<SkOnce::State>::compare_exchange_strong(SkOnce::State&, SkOnce::State, std::memory_order)' ../../third_party/skia/include/gpu/../private/SkOnce.h:36: error: undefined reference to 'std::atomic<SkOnce::State>::store(SkOnce::State, std::memory_order)' ../../third_party/skia/include/gpu/../private/SkOnce.h:42: error: undefined reference to 'std::atomic<SkOnce::State>::load(std::memory_order) const' ../../third_party/skia/include/gpu/../private/SkOnce.h:33: error: undefined reference to 'std::atomic<SkOnce::State>::compare_exchange_strong(SkOnce::State&, SkOnce::State, std::memory_order)' ../../third_party/skia/include/gpu/../private/SkOnce.h:36: error: undefined reference to 'std::atomic<SkOnce::State>::store(SkOnce::State, std::memory_order)' ../../third_party/skia/include/gpu/../private/SkOnce.h:33: error: undefined reference to 'std::atomic<SkOnce::State>::compare_exchange_strong(SkOnce::State&, SkOnce::State, std::memory_order)' ../../third_party/skia/include/gpu/../private/SkOnce.h:36: error: undefined reference to 'std::atomic<SkOnce::State>::store(SkOnce::State, std::memory_order)' clang: error: linker command failed with exit code 1 (use -v to see invocation) ninja: build stopped: subcommand failed.
Message was sent while issue was closed.
A revert of this CL (patchset #4 id:60001) has been created in https://codereview.chromium.org/1898413004/ by mtklein@chromium.org. The reason for reverting is: bust the roll.
The CQ bit was checked by mtklein@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from herb@google.com Link to the patchset: https://codereview.chromium.org/1904483003/#ps80001 (title: "basic uint8_t type")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1904483003/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1904483003/80001
Message was sent while issue was closed.
Description was changed from ========== SkOnce: 2 bytes -> 1 byte This uses the same logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single 3-state byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. This additionally fixes a too-weak memory order bug in SkOncePtr, and adds a big note to explain. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... Committed: https://skia.googlesource.com/skia/+/df02d338be8e3c1c50b48a3a9faa582703a39c07 ========== to ========== SkOnce: 2 bytes -> 1 byte This uses the same logic we worked out for SkOncePtr to reduce the memory footprint of SkOnce from a done byte and lock byte to a single 3-state byte: - NotStarted: no thread has tried to run fn() yet - Active: a thread is running fn() - Done: fn() is complete Threads which see Done return immediately. Threads which see NotStarted try to move to Active, run fn(), then move to Done. Threads which see Active spin until the active thread moves to Done. This additionally fixes a too-weak memory order bug in SkOncePtr, and adds a big note to explain. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&is... Committed: https://skia.googlesource.com/skia/+/df02d338be8e3c1c50b48a3a9faa582703a39c07 Committed: https://skia.googlesource.com/skia/+/650f9e9a2630026d578970c6d031d7d4644f63b4 ==========
Message was sent while issue was closed.
Committed patchset #5 (id:80001) as https://skia.googlesource.com/skia/+/650f9e9a2630026d578970c6d031d7d4644f63b4 |