1. 18 Dec, 2019 8 commits
    • Kirill Smelkov's avatar
      bigfile/py: Move data structures to public .h file · 907bd9d4
      Kirill Smelkov authored
      This is needed so that e.g. a Python class implemented in C or Cython
      (cdef class) could inherit from PyBigFile.
      
      Don't put _bigfile.h into separate include/ directory, and keep it along
      main .c file, similarly to how pygolang is organized.
      907bd9d4
    • Kirill Smelkov's avatar
      bigfile/py: Provide package-level documentation · 3684d164
      Kirill Smelkov authored
      Provide package-level documentation that gives brief overview of what
      this package does. Split internal notes into separate comment.
      3684d164
    • Kirill Smelkov's avatar
      bigfile/py: Stop using Plan9 C extensions · bf44905b
      Kirill Smelkov authored
      Starting from 5755a6b3 (Basic setup.py / Makefile to build/install/sdist
      stuff + bigfile.so skeleton) and 35eb95c2 (bigfile: Python wrapper
      around virtual memory subsystem) we were using Plan9 C extensions[1] for
      simple inheritance. Those extensions are supported by GCC with
      -fplan9-extensions option. However that option is supported only for C,
      while for C++ it does not work at all with error produced by the compiler
      on Plan9 syntax.
      
      Soon we'll need to add another extension - written in C++ - to
      wendelin.core . This extension will be providing client side of WCFS and
      integrating that with virtmem. In that extension we'll need to use
      _bigfile data structures - in particular we'll need to use PyBigFile and
      extend it with another `cdef class` children written in Cython/C++.
      
      This patch prepares for that: first stop using Plan9 C extensions in
      _bigfile py module data structures and adapt the code correspondingly.
      In the next patch we'll move those data structures into an .h file.
      
      We don't drop -fplan9-extensions from setup.py, because Plan9-style
      inheritance continues to be used internally by virtmem - e.g. in
      ram_shmfs.c and friends.
      
      A bit pity to drop that good stuff, but given that we'll need to use C++
      for WCFS client for other good stuff provided by pygolang[2], it is a
      reasonable compromise.
      
      [1] http://9p.io/sys/doc/comp.html  "Extensions" section
      [2] https://pypi.org/project/pygolang
      bf44905b
    • Kirill Smelkov's avatar
      bigfile/zodb: Factor-out LivePersistent into -> lib/zodb · c02776e9
      Kirill Smelkov authored
      It was from long-ago marked as "XXX move to common place".
      c02776e9
    • Kirill Smelkov's avatar
      bigfile/zodb: FIXME invalidations are not working correctly on blocks topology change · 8c32c9f6
      Kirill Smelkov authored
      I noticed this while working on WCFS: if file blocks topology change,
      the invalidation process is not working correctly. It is also not
      correct with respect to live cache pressure.
      
      Add FIXME in the code and test for live cache pressure.
      
      kirr/wendelin.core@5a4562fc
      kirr/wendelin.core@48eb692f
      kirr/wendelin.core@d1a579b2
      kirr/wendelin.core@69c94fbc
      8c32c9f6
    • Kirill Smelkov's avatar
      bigfile/zodb: Explain why we always mark ZBlk object changed if block data change · d27ade8e
      Kirill Smelkov authored
      For ZBlk0 this is trivial, but for ZBlk1 it may seem that we could avoid
      changing ZBlk object itself and mark only pointed-to ZData object as
      changed. However that would be not correct to do if we consider
      invalidations.
      
      Noticed while working on WCFS.
      d27ade8e
    • Kirill Smelkov's avatar
      *: Add package-level documentation to ZODB-related packages · d5e0d2f9
      Kirill Smelkov authored
      Add package-level documentation to
      
        - bigfile/file_zodb.py,
        - bigarray/array_zodb.py, and
        - lib/zodb.py
      
      The most interesting read is file_zodb.py .
      
      Slightly improve documenation for functions in a couple of places.
      
      Improving documentation was long overdue and it is improved only slightly by this commit.
      d5e0d2f9
    • Kirill Smelkov's avatar
      tests: Keep ZEO test database on /tmp/ · 70c998c1
      Kirill Smelkov authored
      We already keep FileStorage test database on /tmp/ and NEO itself (via
      neo.tests.functional.NEOCluster) also keeps test data on tmpfs. However
      test database for ZEO was created in current directory and was wearing
      out SSD unnecessarily.
      
      FIXME zeo_forker currently does not provide API to keep all server files
      in particular place. This way server conf and log are still emitted in
      current directory, but at least we move data.fs away. Since conf and log
      are uniquely named, e.g. server-<ΧΧΧ>.conf and tmpYYY.log, and it was
      only that Data.fs was named non-uniquely, by moving Data.fs into unique
      per-server place, this also helps with-ZEO tests to execute correctly in
      parallel with `tox -p`.
      70c998c1
  2. 04 Dec, 2019 2 commits
  3. 29 Sep, 2019 1 commit
  4. 18 Sep, 2019 1 commit
  5. 15 Jul, 2019 1 commit
    • Kirill Smelkov's avatar
      bigfile/py: It is ok to have .fileh_open() as BigFile method · 7ee02038
      Kirill Smelkov authored
      There was an XXX of whether fileh_open should be a BigFile method or
      global function. However if it would be a global function it will need
      to anyway accept file parameter to indicate which file is opened, and
      that in turn suggests that it should be a file method. Remove XXX.
      7ee02038
  6. 12 Jul, 2019 3 commits
    • Kirill Smelkov's avatar
      */tests: Use defer instead of finally · 2b457640
      Kirill Smelkov authored
      try/finally was used in a couple of places to save/restore default ZBlk
      format setting. Move the restore part close to save with the help of
      defer.
      2b457640
    • Kirill Smelkov's avatar
      *: Use defer for dbclose & friends · 5c8340d2
      Kirill Smelkov authored
      For tests this makes sure that if one test fails, it won't make following
      tests fail just because the next test will fail trying to lock test database.
      
      For regular code (demo_zbigarray.py) this is also a good thing to do -
      to always close the database irregardless of whether an exception was
      raised before program reached end of main.
      
      Pygolang becomes regular - not test only - dependency. Being regular
      dependency is currently required only by demo_zbigarray.py, but it will
      be also used in upcoming wcfs, so adding pygolang into wendelin.core
      dependencies aligns with the plan.
      
      dbclose now uses defer almost everywhere - there are still few places in
      tests, where one test function is opening/closing test database multiple
      times - those were not (yet ?) converted.
      5c8340d2
    • Kirill Smelkov's avatar
      */tests: Use pytest.raises in modern way · b12e319e
      Kirill Smelkov authored
      Instead of
      
      	raises(Exception, 'code')
      
      do
      
      	with raises(Exception):
      		code
      
      This removes lots of warnings, similar to below example:
      
      	bigfile/tests/test_basic.py::test_basic
      	  /home/kirr/src/wendelin/wendelin.core/bigfile/tests/test_basic.py:79: PytestDeprecationWarning: raises(..., 'code(as_a_string)') is deprecated, use the context manager form or use `exec()` directly
      
      	  See https://docs.pytest.org/en/latest/deprecations.html#raises-warns-exec
      	    raises(ROAttributeError, "f.blksize = 1") # RO attribute
      b12e319e
  7. 11 Jul, 2019 3 commits
  8. 10 Jul, 2019 2 commits
  9. 09 Jul, 2019 2 commits
  10. 08 Jul, 2019 6 commits
    • Kirill Smelkov's avatar
      bigfile/test/test_ram: Don't forget to free allocated Page structs · e8eca379
      Kirill Smelkov authored
      test_ram is low-level test that tests RAM pages allocation/mmapping.
      As allocated pages are not integrated with virtmem (not added to any
      file mapping and RAM->lru_list) the Page structs have to be explicitly
      freed. Fixes e.g.
      
      	Direct leak of 80 byte(s) in 1 object(s) allocated from:
      	    #0 0x7ff29af46518 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
      	    #1 0x56131dc22289 in zalloc include/wendelin/utils.h:67
      	    #2 0x56131dc225d6 in ramh_alloc_page bigfile/tests/../ram.c:41
      	    #3 0x56131dc2a19e in main bigfile/tests/test_ram.c:130
      	    #4 0x7ff29ac9f09a in __libc_start_main ../csu/libc-start.c:308
      e8eca379
    • Kirill Smelkov's avatar
      bigfile: RAM must be explicitly free'ed after close · f688a31d
      Kirill Smelkov authored
      Else on-heap allocated RAM object is leaked. Fixes e.g. the following
      error on ASAN:
      
      	Direct leak of 56 byte(s) in 1 object(s) allocated from:
      	    #0 0x7fc9ef390518 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
      	    #1 0x555ca792f309 in zalloc include/wendelin/utils.h:67
      	    #2 0x555ca7935f9a in ram_limited_new bigfile/tests/../../t/t_utils.c:35
      	    #3 0x555ca793a0ba in test_file_access_synthetic bigfile/tests/test_virtmem.c:292
      	    #4 0x555ca7967bc4 in main bigfile/tests/test_virtmem.c:1121
      	    #5 0x7fc9ef0e909a in __libc_start_main ../csu/libc-start.c:308
      f688a31d
    • Kirill Smelkov's avatar
      bigfile/test: Don't forget to close opened RAM · f1931264
      Kirill Smelkov authored
      Only one place that was using ram_new was missing to call ram_close in
      the end.
      f1931264
    • Kirill Smelkov's avatar
      tests: TSAN no longer fails on test_virtmem · e87d6801
      Kirill Smelkov authored
      For failing case compiler-rt support was added in 2014 - 5 years ago
      (see links in removed code).
      e87d6801
    • Kirill Smelkov's avatar
    • Kirill Smelkov's avatar
      3rdparty/ccan: Update · b3636a08
      Kirill Smelkov authored
      Just an update to latest CCAN - there is actually no changes to modules
      that we use (tap, array_size, minmax, bitmap, build_assert)
      b3636a08
  11. 18 Jun, 2019 4 commits
    • Kirill Smelkov's avatar
      wendelin.core v0.13 · b26ba558
      Kirill Smelkov authored
      b26ba558
    • Kirill Smelkov's avatar
      tox -= Python3.5 · 76e8dc34
      Kirill Smelkov authored
      Let's keep on test coverage for last 2 stable Python releases.
      76e8dc34
    • Kirill Smelkov's avatar
      Fix build for Python 3.7 · bca5f79e
      Kirill Smelkov authored
      Starting from Python 3.7 the place to keep exception state was changed:
      https://github.com/python/cpython/commit/ae3087c638
      
      NOTE ZEO4 does not wok with Python3.7, because ZEO4 uses "async" for a
      variable and that breaks because starting from Python3.7 "async" became
      a keyword.
      
      After the fix wendelin.core tests pass under all python2.7, python3.6
      and python3.7.
      bca5f79e
    • Kirill Smelkov's avatar
      tox: ZODB5.test.util needs mock · 6b5384ae
      Kirill Smelkov authored
      Dependency added here:
      
      	https://github.com/zopefoundation/ZODB/commit/e0bc8bd567
      
      If we don't provide mock, e.g. py27-ZODB5-*-zeo-* breaks:
      
      	    def setup_module():
      	        global testdb
      	>       testdb = getTestDB()
      
      	bigarray/tests/test_arrayzodb.py:38:
      	_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
      	.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/wendelin/lib/testing.py:342: in getTestDB
      	    testdb = testdb_factory(testdb_uri)
      	.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/wendelin/lib/testing.py:245: in __init__
      	    from ZEO.tests import forker
      	.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/ZEO/tests/forker.py:29: in <module>
      	    import ZODB.tests.util
      	_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
      
      	    """
      	    from ZODB.MappingStorage import DB
      
      	    import atexit
      	    import os
      	    import persistent
      	    import re
      	    import tempfile
      	    import time
      	    import transaction
      	    import unittest
      	    import warnings
      	    import ZODB.utils
      	    from ZODB.Connection import TransactionMetaData
      	    import zope.testing.setupstack
      	    from zope.testing import renormalizing
      
      	    try:
      	        from unittest import mock
      	    except ImportError:
      	>       import mock
      	E       ImportError: No module named mock
      
      	.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/ZODB/tests/util.py:35: ImportError
      6b5384ae
  12. 23 May, 2019 2 commits
    • Kirill Smelkov's avatar
      tox: v↑ NumPy to 2 latest releases · 7fd83b61
      Kirill Smelkov authored
      7fd83b61
    • Kirill Smelkov's avatar
      bigfile/zodb: Resync _ZBigFileH to Connection.transaction_manager on every connection reopen · d9d6adec
      Kirill Smelkov authored
      This continues c7c01ce4 (bigfile/zodb: ZODB.Connection can migrate
      between threads on close/open and we have to care): Until now we were
      retrieving zconn.transaction_manager on _ZBigFileH init, and further using
      that transaction manager for every connection reopen. However that is
      not correct because on every reopen connection can be given new
      transaction manager.
      
      We were not practically hitting the bug because until recently ZODB was,
      by default, using the same ThreadTransactionManager manager instance as
      Connection.transaction_manager for all connections, and not doing all
      steps needed to keep _ZBigFileH.transaction_manager in sync to
      Connection was forgiven - a particular transaction manager that was used
      was TransactionManager instance implicitly associated with current
      thread by global threading.Local transaction.manager . However starting
      from ZODB 5.5.0 Connection code was changed to remember as
      .transaction_manager the particular TransactionManager instance without
      any threading.Local games:
      
          https://github.com/zopefoundation/ZODB/commit/b6ac40f153
          https://github.com/zopefoundation/ZODB/issues/208
          https://github.com/zopefoundation/ZODB/pull/226
      
      Given that we were not syncing properly that broke wendelin.core tests, for
      example:
      
          bigfile/tests/test_filezodb.py::test_bigfile_filezodb_vs_conn_migration Exception in thread Thread-1:
          Traceback (most recent call last):
            File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
              self.run()
            File "/usr/lib/python2.7/threading.py", line 754, in run
              self.__target(*self.__args, **self.__kwargs)
            File "/home/kirr/src/wendelin/wendelin.core/bigfile/tests/test_filezodb.py", line 401, in T11
              transaction.commit()    # should be nothing
            File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_manager.py", line 252, in commit
              return self.manager.commit()
            File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_manager.py", line 131, in commit
              return self.get().commit()
            File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_transaction.py", line 298, in commit
              self._synchronizers.map(lambda s: s.beforeCompletion(self))
            File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/weakset.py", line 61, in map
              f(elt)
            File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_transaction.py", line 298, in <lambda>
              self._synchronizers.map(lambda s: s.beforeCompletion(self))
            File "/home/kirr/src/wendelin/wendelin.core/bigfile/file_zodb.py", line 671, in beforeCompletion
              assert txn is zconn.transaction_manager.get()
          AssertionError
      
      What is happening here is that one thread used the connection and
      ZBigFile/_ZBigFileH associated with it, then the connection was closed
      and released to DB pool. Then the connection was reopened but by another
      thread and thus with different TransactionManager instance and oops -
      _ZBigFileH.transaction_manager is different because it is
      TransactionManager instance that was used by the first thread.
      
      Fix it by resyncing _ZBigFileH.transaction_manager on every
      connection reopen. No new test as existing tests already cover the
      problem when run with ZODB >= 5.5.0 .
      d9d6adec
  13. 03 May, 2019 1 commit
    • Kirill Smelkov's avatar
      t/qemu-runlinux: Issue terminal init before running program · 89fb8992
      Kirill Smelkov authored
      This continues 6ab95220 (t/qemu-runlinux: Issue terminal resize before
      running program) and fully initializes terminal before spawning user
      application.
      
      This has practical effect to restore line wrapping for xterm, as kernel,
      initially assuming it has "linux" type terminal, somehow messes xterm
      settings: before the patch lines that were wider than terminal width were
      not wrapped and characters in the last position were printed over each
      other. After the patch printed lines are automatically wrapped and test
      output is not lost.
      
      Tput hint found here:
      
      	https://unix.stackexchange.com/questions/105958
      89fb8992
  14. 17 Mar, 2019 1 commit
    • Kirill Smelkov's avatar
      t/qemu-runlinux: Kernel verbosity control via -v · 208aca62
      Kirill Smelkov authored
      	0: ERROR+ on boot/run
      	1: INFO+  on      run
      	2: INFO+  on boot/run
      	3: DEBUG+ on boot/run
      
      It is convenient not to see large kernel boot log on every test run. "1"
      (single -v) is also convenient: one can skip the boot log but still see
      details of what is going on when test workload is run. -vv and -vvv are
      there to see full picture.
      208aca62
  15. 27 Feb, 2019 3 commits