powa-team / powa

PostgreSQL Workload Analyzer
http://powa.readthedocs.io/
PostgreSQL License
768 stars 57 forks source link

Timeline for Windows support? #24

Closed christopherliu closed 5 years ago

christopherliu commented 10 years ago

I'd love to try powa on my Windows box, if possible.

marco44 commented 10 years ago

You should be able to, if you manage to compile the powa extension. The rest is Perl, so it should be portable.

We have no Windows environment to test it, and no good knowledge about Windows. If you know how to do this, a patch is very welcome.

firedeepan commented 7 years ago

I tried to compile powa,c file in visual studio. But I am getting error on:

time_powa_frequency.tv_sec = powa_frequency / 1000; /* Seconds */ time_powa_frequency.tv_usec = 0;

These 2 lines. unable to resolve tv_sec, tv_usec. Compilation error is: union "_LARGE_INTEGER" has no field "tv_sec"

rjuju commented 7 years ago

Hello,

Indeed, instr_time is not implemented as a timeval on windows.

I'm not at all familiar with win32 portability, so can you try to apply this patch and tell me if it compiles, and works as intended (ie. always have powa.frequency ms between two snaphots):

diff --git a/powa.c b/powa.c
index b8dfe8c..0093838 100644
--- a/powa.c
+++ b/powa.c
@@ -94,8 +94,12 @@ void
 compute_powa_frequency(void)
 {
    /* Initialize time_powa_frequency to do maths with it */
+#ifndef WIN32
    time_powa_frequency.tv_sec = powa_frequency / 1000; /* Seconds */
    time_powa_frequency.tv_usec = 0;
+#else
+   time_powa_frequency.QuadPart = powa_frequency / 1000 * GetTimerFrequency();
+#endif   /* WIN32 */
 }

 /* Test if powa is disabled and validity of powa_frequency */
firedeepan commented 7 years ago

Hi, Thank you for the fix, I was able to get rid of the compilation errors. But still the build fails with following errors. (Error Log)

1>powa.obj : error LNK2001: unresolved external symbol _ResetLatch 1>powa.obj : error LNK2001: unresolved external symbol _DefineCustomStringVariable 1>powa.obj : error LNK2001: unresolved external symbol impprocess_shared_preload_libraries_in_progress 1>powa.obj : error LNK2001: unresolved external symbol _pgstat_clear_snapshot 1>powa.obj : error LNK2001: unresolved external symbol _tuplestore_begin_heap 1>powa.obj : error LNK2001: unresolved external symbol _SetCurrentStatementStartTimestamp 1>powa.obj : error LNK2001: unresolved external symbol _RegisterBackgroundWorker 1>powa.obj : error LNK2001: unresolved external symbol _errfinish 1>powa.obj : error LNK2001: unresolved external symbol _errstart 1>powa.obj : error LNK2001: unresolved external symbol impMyProc 1>powa.obj : error LNK2001: unresolved external symbol _elog_finish 1>powa.obj : error LNK2001: unresolved external symbol _ProcessConfigFile 1>powa.obj : error LNK2001: unresolved external symbol _appendStringInfo 1>powa.obj : error LNK2001: unresolved external symbol _pgstat_report_activity 1>powa.obj : error LNK2001: unresolved external symbol _Float8GetDatum 1>powa.obj : error LNK2001: unresolved external symbol _BackgroundWorkerInitializeConnection 1>powa.obj : error LNK2001: unresolved external symbol _pfree 1>powa.obj : error LNK2001: unresolved external symbol _pgstat_report_stat 1>powa.obj : error LNK2001: unresolved external symbol _errmsg 1>powa.obj : error LNK2001: unresolved external symbol _quote_identifier 1>powa.obj : error LNK2001: unresolved external symbol _PushActiveSnapshot 1>powa.obj : error LNK2001: unresolved external symbol _pqsignal 1>powa.obj : error LNK2001: unresolved external symbol _initStringInfo 1>powa.obj : error LNK2001: unresolved external symbol _PopActiveSnapshot 1>powa.obj : error LNK2001: unresolved external symbol _BackgroundWorkerUnblockSignals 1>powa.obj : error LNK2001: unresolved external symbol _StartTransactionCommand 1>powa.obj : error LNK2001: unresolved external symbol _get_call_result_type 1>powa.obj : error LNK2001: unresolved external symbol _SPI_connect 1>powa.obj : error LNK2001: unresolved external symbol _DefineCustomBoolVariable 1>powa.obj : error LNK2001: unresolved external symbol _SET_8_BYTES 1>powa.obj : error LNK2001: unresolved external symbol _elog_start 1>powa.obj : error LNK2001: unresolved external symbol _hash_seq_init 1>powa.obj : error LNK2001: unresolved external symbol impMyDatabaseId 1>powa.obj : error LNK2001: unresolved external symbol _DefineCustomIntVariable 1>powa.obj : error LNK2001: unresolved external symbol _SPI_finish 1>powa.obj : error LNK2001: unresolved external symbol impwork_mem 1>powa.obj : error LNK2001: unresolved external symbol _SetLatch 1>powa.obj : error LNK2001: unresolved external symbol _WaitLatch 1>powa.obj : error LNK2001: unresolved external symbol _errcode 1>powa.obj : error LNK2001: unresolved external symbol _pgstat_fetch_stat_dbentry 1>powa.obj : error LNK2001: unresolved external symbol _CommitTransactionCommand 1>powa.obj : error LNK2001: unresolved external symbol _SPI_execute 1>powa.obj : error LNK2001: unresolved external symbol _pg_snprintf 1>powa.obj : error LNK2001: unresolved external symbol impCurrentMemoryContext 1>powa.obj : error LNK2001: unresolved external symbol _hash_seq_search 1>powa.obj : error LNK2001: unresolved external symbol _set_ps_display 1>powa.obj : error LNK2001: unresolved external symbol _tuplestore_putvalues 1>powa.obj : error LNK2001: unresolved external symbol _GetTransactionSnapshot 1>C:\Users\Deepan\documents\visual studio 2015\Projects\PostgresExtension\Release\PostgresExtension.dll : fatal error LNK1120: 48 unresolved externals 1>Done Building Project "C:\Users\Deepan\documents\visual studio 2015\Projects\PostgresExtension\PostgresExtension\PostgresExtension.vcxproj" (Build target(s)) -- FAILED.

I am not sure whether this is a powa.c issue or a reference library issue. But I was able to build a demo plugin successfully. If you have a clue you can tell me. I will keep trying to make this extension work in windows.

rjuju commented 7 years ago

Yes, this is not powa related. I never tried to compile an extension on windws, but you can try to see these documentations:

rjuju commented 7 years ago

@firedeepan have you been able to compile the extension on windows?

firedeepan commented 7 years ago

@rjuju I was not able to compile it with Visual Studio. I am getting the same error even though all the references are correct. I am planing to add this to the contrib directory and compile it using MSYS2. I will update the status here.

rjuju commented 7 years ago

Ok, thank you for the feedback. In this case, you'll probably need to modify the Makefile to be similar to the official contribs, like this patch:

diff --git a/Makefile b/Makefile
index e7b5975..77903a5 100644
--- a/Makefile
+++ b/Makefile
@@ -22,5 +22,13 @@ release-zip: all
    rm ./powa-$(EXTVERSION) -rf

 DATA = $(wildcard *--*.sql)
+ifdef USE_PGXS
+PG_CONFIG = pg_config
 PGXS := $(shell $(PG_CONFIG) --pgxs)
 include $(PGXS)
+else
+subdir = contrib/powa-archivist
+top_builddir = ../..
+include $(top_builddir)/src/Makefile.global
+include $(top_srcdir)/contrib/contrib-global.mk
+endif
firedeepan commented 7 years ago

@rjuju Thanks for the patch. I will update you soon.

rjuju commented 5 years ago

I added a NO_PGXS option in powa-archivist (https://github.com/powa-team/powa-archivist/commit/38c2c8b76135125913e790d4691d6c221aa3987a), so if that was helpful you won't require a local patch anymore.